<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
</body>
<script>
let onWatch = (obj, setBind, getLogger) => {
    let handler = {
        get(target, property, receiver) {
            getLogger(target, property)
            return Reflect.get(target, property, receiver)
        },
        set(target, property, value, receiver) {
            setBind(value)
            return Reflect.set(target, property, value)
        }
    }
    return new Proxy(obj, handler)
}

// let obj = { a: 1 }
let obj = [{a: 3},4];
let value
let p = onWatch(
    obj,
    v => {
        value = v
    },
    (target, property) => {
        console.log(`Get '${property}' = ${target[property]}`)
    }
)
console.log(p[0], p[1]);
p[0].a = 2;
console.log(p);
</script>
</html>